import type { setType } from './types'
import { defineStore } from 'pinia'
import axios from 'axios'

export const useSettingStore = defineStore({
  id: 'setting',
  state: (): setType => ({
    title: '',
    baseUrl: '',
  }),
  getters: {},
  actions: {
    async getServerConfig() {
      const { data: config } = await axios.get<ServerConfigs>('./config.json')
      if (config && typeof config === 'object') {
        this.title = config.Title
        this.baseUrl = config.BaseUrl
      }
    },
  },
})
